package com.gopay.cron.service.cloud.impl;

import com.gopay.common.constants.trans.PayChannel;
import com.gopay.common.cps.dao.order.CpsGeneralMainOrderQueryDAO;
import com.gopay.common.datasource.DBType;
import com.gopay.common.datasource.DbContextHolder;
import com.gopay.common.domain.cps.CpsGenMainOrder;
import com.gopay.common.order.dao.CommonQueryDAO;
import com.gopay.common.util.DateUtils;
import com.gopay.common.util.FtpUtil;
import com.gopay.cron.service.cloud.CloudAccountGenFtpFileService;
import com.gopay.cron.service.cloud.gen.CloudOrderFileGenHelper;
import com.gopay.cron.service.cloud.gen.bean.RecvFileInfo;
import com.gopay.cron.service.cloud.gen.bean.RefundFileInfo;
import com.gopay.cron.service.cloud.gen.bean.TransferFileInfo;
import com.gopay.cron.service.cloud.gen.bean.WithdrawFileInfo;
import com.gopay.cron.web.vo.CloudAccountStatementVO;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.File;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

/**
 * 云账户成FTP文件实现类
 * Created by Lenovo-songfengli on 2017/8/22.
 */
@Service("cloudAccountGenFtpFileService")
public class CloudAccountGenFtpFileServiceImpl implements CloudAccountGenFtpFileService{

    private static Logger logger = Logger.getLogger(CloudAccountGenFtpFileServiceImpl.class);

    @Resource(name = "commonQueryDAO")
    private CommonQueryDAO commonQueryDAO;

    @Resource(name = "cpsGeneralMainOrderQueryDAO")
    private CpsGeneralMainOrderQueryDAO cpsGeneralMainOrderQueryDAO;

    @Resource(name = "cloudFtpConfig")
    private Map<String, String> cloudFtpConfig;

    @Override
    public boolean genFile(String filePath,String checkDate,String custId, String acctId,String prodCode) {
        CloudOrderFileGenHelper helper = queryOrder(checkDate,custId,acctId);
        StringBuilder genPath = new StringBuilder();
        genPath.append(filePath).append(custId).append(File.separator).append(checkDate).append(File.separator);
        String genPathString =genPath.toString();
        helper.setFilePath(genPathString);
        helper.setProdCode(prodCode);
        helper.setCheckDate(checkDate.replace("-",""));
        String acctIdSub = acctId.substring(acctId.length() - 4,acctId.length());
        helper.setAcctId(acctIdSub);
        try {
            helper.genFtpFile();
            Set<String> fileNameSet = new HashSet<>();
            //上传FTP文件名称
            if("GNST".equals(prodCode)) {
                String recvFileName = checkDate.replace("-", "") + "-" + acctIdSub + "-" + RecvFileInfo.fileFtpName + ".csv";
                String refundFileName = checkDate.replace("-", "") + "-" + acctIdSub + "-" + RefundFileInfo.fileFtpName + ".csv";
                String transferFileName = checkDate.replace("-", "") + "-" + acctIdSub + "-" + TransferFileInfo.fileFtpName + ".csv";
                fileNameSet.add(recvFileName);
                fileNameSet.add(refundFileName);
                fileNameSet.add(transferFileName);
            }
            if("CLOUD".equals(prodCode)) {
                String withdrawFileName = checkDate.replace("-", "") + "-" + acctIdSub + "-" + WithdrawFileInfo.fileFtpName + ".csv";
                fileNameSet.add(withdrawFileName);
            }
            uploadFileToFtp(genPathString,fileNameSet);

        } catch (Exception e) {
            logger.error("生成文件出错",e);
            return false;
        }
        return true;
    }


    private CloudOrderFileGenHelper queryOrder(String checkDate,String custId,String acctId) {
        DbContextHolder.setDbType(DBType.DS_ONLY_READ.value);
        String beginTime = checkDate + "00:00:00";
        String endTime = checkDate + "23:59:59";
        return buildResult(custId,acctId,beginTime,endTime);
    }



    private CloudOrderFileGenHelper buildResult(String custId,String acctId,String beginTime,String endTime) {

        CloudOrderFileGenHelper helper = new CloudOrderFileGenHelper();
        //收款类交易合计与明细
        List<Object[]> recvTotal = commonQueryDAO.findBySql(buildRecvTotalSql(custId,acctId,beginTime,endTime));
        List<Object[]> recvList = commonQueryDAO.findBySql(buildRecvQuerySql(custId,acctId,beginTime,endTime));

        //收款类退款交易合计与明细
        List<Object[]> refundTotal = commonQueryDAO.findBySql(buildRefundTotalSql(custId,acctId,beginTime,endTime));
        List<Object[]> refundList = commonQueryDAO.findBySql(buildRefundQuerySql(custId,acctId,beginTime,endTime));

        //转账类交易合计与明细
        List<Object[]> transferTotal = commonQueryDAO.findBySql(buildTransferTotalSql(custId,acctId,beginTime,endTime));
        List<Object[]> transferList = commonQueryDAO.findBySql(buildTransferQuerySql(custId,acctId,beginTime,endTime));

        //提现类交易合计与明细
        List<Object[]> withdrawTotal = commonQueryDAO.findBySql(buildWithdrawTotalSql(custId,acctId,beginTime,endTime));
        List<Object[]> withdrawList = commonQueryDAO.findBySql(buildWithdrawQuerySql(custId,acctId,beginTime,endTime));

        //收款类交易
        if(recvList != null) {
            //合计
            CloudAccountStatementVO recvTotalVo = new CloudAccountStatementVO();
            recvTotalVo.setGopayAcct(acctId);
            recvTotalVo.setTotalCount((recvTotal.get(0)[0]).toString());
            if(recvTotal.get(0)[1] != null){
                recvTotalVo.setTotalTxnAmt(((BigDecimal) recvTotal.get(0)[1]).setScale(2,RoundingMode.HALF_UP).toString());
            }else{
                recvTotalVo.setTotalTxnAmt("0.00");
            }
            if(recvTotal.get(0)[2] != null){
                recvTotalVo.setTotalFeeAmt(((BigDecimal) recvTotal.get(0)[2]).setScale(2,RoundingMode.HALF_UP).toString());
            }else{
                recvTotalVo.setTotalFeeAmt("0.00");
            }

            helper.addFtpFirstRecvFileLine(recvTotalVo);
            //明细
            for(int i = 0;i<recvList.size();i++) {
                Object[] obj = recvList.get(i);
                CloudAccountStatementVO vo = new CloudAccountStatementVO();
                vo.setGopayOrderId((String) obj[0]);
                vo.setMerOrderId((String) obj[1]);
                vo.setGopayIntTxnCd(translateGopayIntTxnCd((String) obj[2]));
                vo.setReqTime(DateUtils.format((Date) obj[3],"yyyyMMddHHmmss"));
                vo.setTranFinishTime(DateUtils.format((Date) obj[4],"yyyyMMddHHmmss"));
                vo.setMerTxnAmt(((BigDecimal) obj[5]).setScale(2,RoundingMode.HALF_UP).toString());
                vo.setOrderFeeAmt(((BigDecimal) obj[6]).setScale(2, RoundingMode.HALF_UP).toString());
                vo.setPayChannel(PayChannel.translate((String) obj[7]));
                helper.addFtpSecondRecvFileLine(vo);
            }
        }

        //收款类退款
        if(refundList != null) {
            //合计
            CloudAccountStatementVO refundTotalVo = new CloudAccountStatementVO();
            refundTotalVo.setGopayAcct(acctId);
            refundTotalVo.setTotalCount((refundTotal.get(0)[0]).toString());
            if(refundTotal.get(0)[1] != null){
                refundTotalVo.setTotalTxnAmt(((BigDecimal) refundTotal.get(0)[1]).setScale(2,RoundingMode.HALF_UP).toString());
            }else{
                refundTotalVo.setTotalTxnAmt("0.00");
            }
            if(refundTotal.get(0)[2] != null){
                refundTotalVo.setTotalFeeAmt(((BigDecimal) refundTotal.get(0)[2]).setScale(2,RoundingMode.HALF_UP).toString());
            }else{
                refundTotalVo.setTotalFeeAmt("0.00");
            }

            helper.addFtpFirstRefundFileLine(refundTotalVo);
            //明细
            for(int i = 0;i<refundList.size();i++) {
                Object[] obj = refundList.get(i);
                CloudAccountStatementVO vo = new CloudAccountStatementVO();
                vo.setGopayOrderId((String) obj[0]);
                vo.setMerOrderId((String) obj[1]);
                if(obj[2] != null){
                    String origGopayOrderId = (String) obj[2]; //原交易国付宝订单号
                    vo.setOrigGopayOrderId(origGopayOrderId);
                    CpsGenMainOrder cpsGenMainOrder =cpsGeneralMainOrderQueryDAO.findByGopayOrderId(origGopayOrderId);
                    if(cpsGenMainOrder != null){
                        vo.setOrigMerOrderId(cpsGenMainOrder.getMerOrderId());
                        vo.setOrigMerTxnAmt((cpsGenMainOrder.getMerTxnAmt()).setScale(2,RoundingMode.HALF_UP).toString());
                    }
                }
                vo.setGopayIntTxnCd(translateGopayIntTxnCd((String) obj[3]));
                vo.setReqTime(DateUtils.format((Date) obj[4],"yyyyMMddHHmmss"));
                if(obj[5] != null){
                    vo.setTranFinishTime(DateUtils.format((Date) obj[5],"yyyyMMddHHmmss"));
                }
                vo.setMerTxnAmt(((BigDecimal) obj[6]).setScale(2,RoundingMode.HALF_UP).toString());
                vo.setOrderFeeAmt(((BigDecimal) obj[7]).setScale(2, RoundingMode.HALF_UP).toString());
                helper.addFtpSecondRefundFileLine(vo);
            }
        }

        //转账类交易
        if(transferList != null) {
            //合计
            CloudAccountStatementVO transferTotalVo = new CloudAccountStatementVO();
            transferTotalVo.setGopayAcct(acctId);
            transferTotalVo.setTotalCount((transferTotal.get(0)[0]).toString());
            if(transferTotal.get(0)[1] != null){
                transferTotalVo.setTotalTxnAmt(((BigDecimal) transferTotal.get(0)[1]).setScale(2,RoundingMode.HALF_UP).toString());
            }else{
                transferTotalVo.setTotalTxnAmt("0.00");
            }
            if(transferTotal.get(0)[2] != null){
                transferTotalVo.setTotalFeeAmt(((BigDecimal) transferTotal.get(0)[2]).setScale(2,RoundingMode.HALF_UP).toString());
            }else{
                transferTotalVo.setTotalFeeAmt("0.00");
            }

            helper.addFtpFirstTransferFileLine(transferTotalVo);
            //明细
            for(int i = 0;i<transferList.size();i++) {
                Object[] obj = transferList.get(i);
                CloudAccountStatementVO vo = new CloudAccountStatementVO();
                vo.setGopayOrderId((String) obj[0]);
                vo.setMerOrderId((String) obj[1]);
                vo.setGopayIntTxnCd(translateGopayIntTxnCd((String) obj[2]));
                vo.setReqTime(DateUtils.format((Date) obj[3],"yyyyMMddHHmmss"));
                if(obj[4] != null) {
                    vo.setTranFinishTime(DateUtils.format((Date) obj[4], "yyyyMMddHHmmss"));
                }
                vo.setMerTxnAmt(((BigDecimal) obj[5]).setScale(2,RoundingMode.HALF_UP).toString());
                vo.setOrderFeeAmt(((BigDecimal) obj[6]).setScale(2, RoundingMode.HALF_UP).toString());
                vo.setOrderFeePayer(translateOrderFeePayer((String) obj[7]));
                vo.setAgreeId((String) obj[8]);
                helper.addFtpSecondTransferFileLine(vo);
            }
        }

        //提现类交易
        if(withdrawList != null) {
            //合计
            CloudAccountStatementVO withdrawTotalVo = new CloudAccountStatementVO();
            withdrawTotalVo.setTotalCount((withdrawTotal.get(0)[0]).toString());
            if(withdrawTotal.get(0)[1] != null){
                withdrawTotalVo.setTotalTxnAmt(((BigDecimal) withdrawTotal.get(0)[1]).setScale(2,RoundingMode.HALF_UP).toString());
            }else{
                withdrawTotalVo.setTotalTxnAmt("0.00");
            }
            if(withdrawTotal.get(0)[2] != null){
                withdrawTotalVo.setTotalFeeAmt(((BigDecimal) withdrawTotal.get(0)[2]).setScale(2,RoundingMode.HALF_UP).toString());
            }else{
                withdrawTotalVo.setTotalFeeAmt("0.00");
            }

            helper.addFtpFirstWithdrawFileLine(withdrawTotalVo);
            //明细
            for(int i = 0;i<withdrawList.size();i++) {
                Object[] obj = withdrawList.get(i);
                CloudAccountStatementVO vo = new CloudAccountStatementVO();
                vo.setGopayOrderId((String) obj[0]);
                vo.setMerOrderId((String) obj[1]);
                vo.setGopayIntTxnCd(translateGopayIntTxnCd((String) obj[2]));
                vo.setReqTime(DateUtils.format((Date) obj[3],"yyyyMMddHHmmss"));
                if(obj[4] != null){
                    vo.setTranFinishTime(DateUtils.format((Date) obj[4],"yyyyMMddHHmmss"));
                }
                vo.setMerTxnAmt(((BigDecimal) obj[5]).setScale(2,RoundingMode.HALF_UP).toString());
                vo.setOrderFeeAmt(((BigDecimal) obj[6]).setScale(2, RoundingMode.HALF_UP).toString());
                vo.setOrderFeePayer(translateOrderFeePayer((String) obj[7]));
                vo.setAgreeId((String) obj[8]);
                helper.addFtpSecondWithdrawFileLine(vo);
            }
        }

        return helper;
    }


    private String buildRecvTotalSql(String custId, String acctId, String beginTime, String endTime) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select count(*),");
        sql.append(" sum(c.mer_txn_amt) as totalAmt,");
        sql.append(" sum(case when c.order_fee_payer ='02' then c.total_order_fee_amt else 0.00 end) as totalFeeAmt ");
        sql.append(" from cps_gen_main_order c       ");
        sql.append(" where c.gopay_int_txn_cd in ('00100')  and c.txn_sta_cd ='20000'") ;
        sql.append(" and c.main_recv_acct = '").append(acctId).append("'");
        sql.append(" and c.main_recv_cust_id = '").append(custId).append("'");
        sql.append(" and c.tran_finish_time>= ");
        sql.append(" to_timestamp('").append(beginTime).append("','yyyy-MM-dd HH24:MI:ss')");
        sql.append(" and c.tran_finish_time <=");
        sql.append(" to_timestamp('").append(endTime).append("','yyyy-MM-dd HH24:MI:ss')");
        return sql.toString();
    }

    private String buildRecvQuerySql(String custId, String acctId, String beginTime, String endTime) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select c.gopay_order_id,                   ");
        sql.append("        c.mer_order_id,                     ");
        sql.append("        c.gopay_int_txn_cd,                 ");
        sql.append("        c.mer_txn_tm,                       ");
        sql.append("        c.tran_finish_time,                 ");
        sql.append("        c.mer_txn_amt,                      ");
        sql.append(" (case when c.order_fee_payer ='02' then c.order_real_fee_amt else 0.00 end) as order_real_fee_amt,");
        sql.append("        c.pay_channel                       ");
        sql.append(" from cps_gen_main_order c       ");
        sql.append(" where c.gopay_int_txn_cd in ('00100')  and c.txn_sta_cd ='20000'") ;
        sql.append(" and c.main_recv_acct = '").append(acctId).append("'");
        sql.append(" and c.main_recv_cust_id = '").append(custId).append("'");
        sql.append(" and c.tran_finish_time>= ");
        sql.append(" to_timestamp('").append(beginTime).append("','yyyy-MM-dd HH24:MI:ss')");
        sql.append(" and c.tran_finish_time <=");
        sql.append(" to_timestamp('").append(endTime).append("','yyyy-MM-dd HH24:MI:ss')");
        return sql.toString();
    }

    private String buildRefundTotalSql(String custId, String acctId, String beginTime, String endTime) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select count(*),");
        sql.append(" sum(c.mer_txn_amt) as totalAmt,");
        sql.append(" sum(case when c.order_fee_payer ='01' then c.total_order_fee_amt else 0.00 end) as totalFeeAmt ");
        sql.append(" from cps_gen_main_order c       ");
        sql.append(" where c.gopay_int_txn_cd in ('01200') ") ;
        sql.append(" and c.pay_acct = '").append(acctId).append("'");
        sql.append(" and c.pay_cust_id = '").append(custId).append("'");
        sql.append(" and c.mer_txn_tm>= ");
        sql.append(" to_timestamp('").append(beginTime).append("','yyyy-MM-dd HH24:MI:ss')");
        sql.append(" and c.mer_txn_tm <=");
        sql.append(" to_timestamp('").append(endTime).append("','yyyy-MM-dd HH24:MI:ss')");
        return sql.toString();
    }

    private String buildRefundQuerySql(String custId, String acctId, String beginTime, String endTime) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select c.gopay_order_id,                   ");
        sql.append("        c.mer_order_id,                     ");
        sql.append("        c.relevance_gopay_order_id,         ");
        sql.append("        c.gopay_int_txn_cd,                 ");
        sql.append("        c.mer_txn_tm,                       ");
        sql.append("        c.tran_finish_time,                 ");
        sql.append("        c.mer_txn_amt,                      ");
        sql.append(" (case when c.order_fee_payer ='01' then c.order_real_fee_amt else 0.00 end) as order_real_fee_amt,");
        sql.append("        c.pay_channel                       ");
        sql.append(" from cps_gen_main_order c       ");
        sql.append(" where c.gopay_int_txn_cd in ('01200') ") ;
        sql.append(" and c.pay_acct = '").append(acctId).append("'");
        sql.append(" and c.pay_cust_id = '").append(custId).append("'");
        sql.append(" and c.mer_txn_tm>= ");
        sql.append(" to_timestamp('").append(beginTime).append("','yyyy-MM-dd HH24:MI:ss')");
        sql.append(" and c.mer_txn_tm <=");
        sql.append(" to_timestamp('").append(endTime).append("','yyyy-MM-dd HH24:MI:ss')");
        return sql.toString();
    }

    private String buildTransferTotalSql(String custId, String acctId, String beginTime, String endTime) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select count(*),");
        sql.append(" sum(c.mer_txn_amt) as totalAmt,");
        sql.append(" sum(c.order_real_fee_amt) as totalFeeAmt ");
        sql.append(" from cps_gen_main_order c       ");
        sql.append(" where c.gopay_int_txn_cd in ('01812') and c.txn_sta_cd ='20000'") ;
        sql.append(" and c.pay_acct = '").append(acctId).append("'");
        sql.append(" and c.pay_cust_id = '").append(custId).append("'");
        sql.append(" and c.mer_txn_tm>= ");
        sql.append(" to_timestamp('").append(beginTime).append("','yyyy-MM-dd HH24:MI:ss')");
        sql.append(" and c.mer_txn_tm <=");
        sql.append(" to_timestamp('").append(endTime).append("','yyyy-MM-dd HH24:MI:ss')");
        return sql.toString();
    }

    private String buildTransferQuerySql(String custId, String acctId, String beginTime, String endTime) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select c.gopay_order_id,                   ");
        sql.append("        c.mer_order_id,                     ");
        sql.append("        c.gopay_int_txn_cd,                 ");
        sql.append("        c.mer_txn_tm,                       ");
        sql.append("        c.tran_finish_time,                 ");
        sql.append("        c.mer_txn_amt,                      ");
        sql.append("        c.order_real_fee_amt,               ");
        sql.append("        c.order_fee_payer,                  ");
        sql.append("        t.AGREE_ID                          ");
        sql.append(" from cps_gen_main_order c       ");
        sql.append(" left join cloud_cust_acct_rel t on t.cust_id = c.main_recv_cust_id");
        sql.append(" where c.gopay_int_txn_cd in ('01812') and c.txn_sta_cd ='20000'") ;
        sql.append(" and c.pay_acct = '").append(acctId).append("'");
        sql.append(" and c.pay_cust_id = '").append(custId).append("'");
        sql.append(" and c.mer_txn_tm>= ");
        sql.append(" to_timestamp('").append(beginTime).append("','yyyy-MM-dd HH24:MI:ss')");
        sql.append(" and c.mer_txn_tm <=");
        sql.append(" to_timestamp('").append(endTime).append("','yyyy-MM-dd HH24:MI:ss')");
        return sql.toString();
    }

    private String buildWithdrawTotalSql(String custId, String acctId, String beginTime, String endTime) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select count(*),");
        sql.append(" sum(c.mer_txn_amt) as totalAmt,");
        sql.append(" sum(c.order_real_fee_amt) as totalFeeAmt ");
        sql.append(" from cps_gen_main_order c       ");
        sql.append(" where c.gopay_int_txn_cd in ('00800') ") ;
        sql.append(" and c.pay_acct in (select t.acct_id from cloud_cust_acct_rel t where t.partner_cust_id = '").append(custId).append("' and t.partner_acct_id = '").append(acctId).append("')");
        sql.append(" and c.mer_txn_tm>= ");
        sql.append(" to_timestamp('").append(beginTime).append("','yyyy-MM-dd HH24:MI:ss')");
        sql.append(" and c.mer_txn_tm <=");
        sql.append(" to_timestamp('").append(endTime).append("','yyyy-MM-dd HH24:MI:ss')");
        return sql.toString();
    }

    private String buildWithdrawQuerySql(String custId, String acctId, String beginTime, String endTime) {
        StringBuilder sql = new StringBuilder();
        sql.append(" select c.gopay_order_id,                   ");
        sql.append("        c.mer_order_id,                     ");
        sql.append("        c.gopay_int_txn_cd,                 ");
        sql.append("        c.mer_txn_tm,                       ");
        sql.append("        c.tran_finish_time,                 ");
        sql.append("        c.mer_txn_amt,                      ");
        sql.append("        c.order_real_fee_amt,               ");
        sql.append("        c.order_fee_payer,                  ");
        sql.append("        t.AGREE_ID                          ");
        sql.append(" from cps_gen_main_order c       ");
        sql.append(" left join cloud_cust_acct_rel t on t.acct_id = c.pay_acct ");
        sql.append(" where c.gopay_int_txn_cd in ('00800') ") ;
        sql.append(" and  t.partner_cust_id = '").append(custId).append("'");
        sql.append(" and t.partner_acct_id = '").append(acctId).append("'");
        sql.append(" and c.mer_txn_tm>= ");
        sql.append(" to_timestamp('").append(beginTime).append("','yyyy-MM-dd HH24:MI:ss')");
        sql.append(" and c.mer_txn_tm <=");
        sql.append(" to_timestamp('").append(endTime).append("','yyyy-MM-dd HH24:MI:ss')");
        return sql.toString();
    }

    private String translateGopayIntTxnCd(String gopayIntTxnCd) {
        String result = "";
        if(gopayIntTxnCd != null) {
            switch (gopayIntTxnCd) {
                case "00100" :
                    result = "网关支付";
                    break;
                case "01200" :
                    result = "收款退款";
                    break;
                case "00700" :
                    result = "付款到银行";
                    break;
                case "01812" :
                    result = "云账户转账";
                    break;
                case "00800" :
                    result = "提现";
                    break;
            }
        }
        return result;
    }

    private String translateOrderFeePayer(String orderFeePayer) {
        String result = "";
        if(orderFeePayer != null) {
            switch (orderFeePayer) {
                case "00" :
                    result = "不涉及";
                    break;
                case "01" :
                    result = "付方承担";
                    break;
                case "02" :
                    result = "收方承担";
                    break;
                case "03" :
                    result = "商城承担";
                    break;
            }
        }
        return result;
    }

    private void uploadFileToFtp(String localPath,Set<String> fileNameSet){
        logger.info("上传FTP文件开始！！！！");
        logger.info("上传FTP的本地文件路径为："+localPath);
        String url = cloudFtpConfig.get("ftp.ip");
        int port = Integer.valueOf(cloudFtpConfig.get("ftp.port"));
        String username = cloudFtpConfig.get("ftp.username");
        String password = cloudFtpConfig.get("ftp.password");
        String ftpPath = cloudFtpConfig.get("ftp.upload.path");
        String encoding = "UTF-8";

        for(String fileName : fileNameSet) {
            logger.info("上传FTP的文件名称是：" + fileName);
            boolean isFtpSuccess = FtpUtil.uploadFile(url,port,username,password,ftpPath,fileName,localPath,fileName,encoding);
            logger.info("上传FTP文件是否成功："+ String.valueOf(isFtpSuccess));
        }
        logger.info("上传FTP文件结束！！！！");
    }

}
